package baidu;

import java.util.Scanner;

//寻找幸运数字
public class FindLuckNum {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			findFirstLuck(a, b);
		}
		scanner.close();
	}

	public static void findFirstLuck(int a, int b) {
		char[] luckNum = String.valueOf(b).toCharArray();
		int j = 0, k = 0;
		char[] num;
		for (int i = a;; i++) {
			num = String.valueOf(i).toCharArray();
			for (j = 0, k = 0; j < num.length; j++) {
				if (k < luckNum.length) {
					if (num[j] == luckNum[k]) {
						k++;
					}
				}
			}
			if (k == luckNum.length) {
				break;
			}
		}
		for (char c : num) {
			System.out.print(c);
		}
	}
}
